<template>
  <view class="wrap">
    <view class="backImage">
      <image src="../../../static/interImage.png" mode="widthFix" class="img"></image>
    </view>
    <uv-navbar fixed title="入会信息" autoBack safeAreaInsetTop placeholder :border='false' bg-color="rgba(0,0,0,0)" titleStyle='color: #FFFFFF' leftIconColor='#FFFFFF'></uv-navbar>
    <view class="box">
      <view class="pb20" v-if="detail.main_teacher_info">
        <view class='test'>*请通过浏览器或pc打开链接进行直播</view>
        <view class='test'>主讲：{{ detail.main_teacher_info.nickname }}</view>
        <view class='test'>频道号：{{ detail.main_teacher_info.channel_id }}</view>
        <view class='test'>密码/邀请码：{{ detail.main_teacher_info.password }}</view>
        <view class='test'>网页开播链接：{{ detail.main_teacher_info.web_url }}</view>
        <view class='test'>启动用户端链接：{{ detail.main_teacher_info.client_url }}</view>
      </view>
      <view v-if="detail.help_teacher_info">
        <view class='test'>助教：{{ detail.help_teacher_info.nickname }}</view>
        <view class='test'>助教后台链接：{{ detail.help_teacher_info.web_url }}</view>
        <view class='test'>频道号：{{ detail.help_teacher_info.channel_id }}</view>
        <view class='test'>密码：{{ detail.help_teacher_info.password }}</view>
      </view>
    </view>
    
    <view class="safe"></view>
    <uv-safe-bottom></uv-safe-bottom>
    <view class="footer">
      <button class="btn" hover-class="none" @click="cope">复制</button>
      <uv-safe-bottom></uv-safe-bottom>
    </view>
  </view>
</template>

<script setup>
import { ref } from 'vue';
import { onLoad } from '@dcloudio/uni-app';
import { get } from '@/api';
import { toast } from '@/common';

let detail = ref({});

onLoad((option) => {
  getData(option.id);
})

function getData(id){
  get('/api/Live/getJoinInfo', { lessonLiveId: id }).then(res => {
    if(res.code == 1){
      const data = res.data;
      detail.value = data;
    }
  })
}
function cope(){
  const test = `
    主讲：${ detail.value.main_teacher_info.nickname }
    频道号：${ detail.value.main_teacher_info.channel_id }
    密码/邀请码：${ detail.value.main_teacher_info.password }
    网页开播链接：${ detail.value.main_teacher_info.web_url }
    启动用户端链接：${ detail.value.main_teacher_info.client_url }\n
    助教：${ detail.value.help_teacher_info.nickname }
    助教后台链接：${ detail.value.help_teacher_info.web_url }
    频道号：${ detail.value.help_teacher_info.channel_id }
    密码：${ detail.value.help_teacher_info.password }
  `
  uni.setClipboardData({
  	data: test,
  	success: function () {
  		toast('复制成功');
  	}
  });
}
</script>

<style lang="scss" scoped>
  .safe{
    width: 100%;
    height: 110rpx;
  }
  .footer{
    width: 100%;
    background-color: #fff;
    padding: 30rpx;
    position: fixed;
    left: 0;
    bottom: 0;
    z-index: 9;
  }
  .box{
    padding: 0 50rpx;
    padding-top: 100rpx;
    position: relative;
    z-index: 2;
    .pb20{
      padding-bottom: 20rpx;
    }
    .test{
      font-weight: 400;
      font-size: 28rpx;
      color: #FFFFFF;
    }
  }
  .backImage{
    width: 100%;
    position: fixed;
    left: 0;
    top: 0;
    z-index: 1;
  }
  .wrap{
    width: 100%;
    min-height: 100vh;
    background-color: #F0F0F0;
  }
</style>